!!!###!!!title=11- How to display a color block area within a specified x-axis range in the chart——VisActor/VChart FAQ documents!!!###!!!!!!###!!!description=---title: How to display a color block area in a chart that covers the specified x-axis range?</br>key words: VisActor,VChart,VTable,VStrory,VMind,VGrammar,VRender,Visualization,Chart,Data,Table,Graph,Gis,LLM--- !!!###!!!

Question title

How to display a color block area in a chart that covers a specified x-axis range?

Problem description

Similar to the effect shown in the figure below, I hope to draw a color block within the specified x-axis range in the chart. How should I configure it in VChart?

Solution

You can achieve this through the markArea component, using the markArea.coordinates property to declare the range of data to be annotated.

  • Coordinates : Support configuring data values, VChart will automatically map the data to canvas coordinates for range drawing.
  markArea: [
    {
      coordinates: [
        {
          Date: 'Jan-20',
          Price: 0.18
        },
        {
          Date: 'Mar-23',
          Price: 0.18
        },
        {
          Date: 'Mar-23',
          Price: 0.12
        },
        {
          Date: 'Jan-20',
          Price: 0.12
        }
      ],
      label: {
        text: 'Electricite prices have surged since 2020',
        position: 'insideTop'
      }
    }
  ],</br>

Code example

https://visactor.io/vchart/demo/marker/mark-area-basic

Results show